//
//  XNStatusViewModel.swift
//  weibo
//
//  Created by 王向宁 on 16/5/25.
//  Copyright © 2016年 王向宁. All rights reserved.
//

import UIKit

class XNStatusViewModel: NSObject {
    
    
    
    var status : XNStatus?
    
    var veritiedImage: UIImage?
    
    var mbrankImage: UIImage?
    
    var headImageURL: NSURL?
    
    init(status : XNStatus) {
        super.init()
        
        self.status = status
        //处理用户等级的图片
        dealMbrankImage()
        //处理认证类型的图片
        dealVeritiedImage()
        //处理用户头像的地址
        headImageURL = NSURL(string: status.user?.profile_image_url ?? "")
        
    }
}

extension XNStatusViewModel {
    private func dealMbrankImage() {
        let mbType = status?.user?.mbrank ?? 0
        
        
        if mbType > 0 && mbType < 7 {
            mbrankImage = UIImage(named: "common_icon_membership_level\(mbType)")
        }
    }
    
    private func dealVeritiedImage() {
        let veriteidType = status?.user?.verified ?? 0
        
        if veriteidType == 1 {
            veritiedImage = UIImage(named: "avatar_vip")
        }
    }
}











